﻿using System;
using System.IO;
using System.Windows.Forms;
using Oxage.Common;

namespace Oxage
{
	public static class AppConfig
	{
		#region Constants
		public const int BalloonTimeout = 3000;
		public const string ProjectUrl = "http://code.google.com/oxmidi";
		#endregion

		#region Properties
		public static bool RunAtStartup
		{
			get
			{
				bool result = false;
				Config.Get("RunAtStartup", out result);
				return result;
			}
			set
			{
				Config.Set("RunAtStartup", value);
			}
		}

		/// <summary>
		/// Gets a value indicating whether application is running for the first time on the computer/system.
		/// </summary>
		public static bool IsFirstRun
		{
			get
			{
				bool result = (!Config.Get("IsFirstRun", out result)); //True if key does not exist
				Config.Set("IsFirstRun", false); //Create a key
				return result;
			}
		}

		/// <summary>
		/// Gets or sets a value indicating whether multiple forms can be displayed.
		/// NOTE: Application may throw exception if the same port is opened twice.
		/// Advanced user should know how to handle that.
		/// </summary>
		public static bool AllowMultipleForms
		{
			get
			{
				bool result = false;
				return Config.Get("AllowMultipleForms", out result) ? result : true /* default */;
			}
			set
			{
				Config.Set("AllowMultipleForms", value);
			}
		}

		/// <summary>
		/// Gets or sets the default profile name. Default profile is loaded at the application startup.
		/// </summary>
		public static string DefaultProfileName
		{
			get
			{
				string result = null;
				Config.Get("DefaultProfileName", out result);
				return result;
			}
			set
			{
				Config.Set("DefaultProfileName", value);
			}
		}

		/// <summary>
		/// Gets the root path for registry settings.
		/// </summary>
		public static string RegistryRootPath
		{
			get
			{
				return @"Software\Oxage\" + Application.ProductName;
			}
		}

		/// <summary>
		/// Gets the base path where plugins should be loaded from.
		/// </summary>
		public static string PluginBasePath
		{
			get
			{
				return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins");
			}
		}
		#endregion
	}
}
